﻿using Little.Soldier.SWIFT;
using Little.Soldier.SWIFT.Definition;
using System.Collections.Generic;
using System.ComponentModel;

namespace Little.Soldier.SWIFT.Messages.Category9
{
  public class MT973 : SwiftMessage
  {
    private static SwiftMessageDefinition MessageDefinition;
    private static SwiftTagDefinition U0002;
    private static SwiftTagSubItemDefinition U0003;
    private static SwiftTagSequenceDefinition U0004;
    private static SwiftTagDefinition U0005;
    private static SwiftTagSubItemDefinition U0006;
    private static SwiftTagDefinition U0007;
    private static SwiftTagSubItemDefinition U0008;

    [Description("Transaction Reference Number")]
    public Tag20 TransactionReferenceNumber_20
    {
      get
      {
        return new Tag20((SwiftElement) this, 0, (SwiftDefinitionElement) MT973.U0002);
      }
    }

    [Description("Transaction Reference Number")]
    public Tag20 Tag20_TransactionReferenceNumber
    {
      get
      {
        return this.TransactionReferenceNumber_20;
      }
    }

    [Description("Message Requested")]
    public MT973.SequenceClass[] Sequence
    {
      get
      {
        int index = -1;
        List<MT973.SequenceClass> list = new List<MT973.SequenceClass>();
        int count;
        do
        {
          ++index;
          MT973.SequenceClass sequenceClass = new MT973.SequenceClass((SwiftElement) this, index, false);
          count = this.ListTags((SwiftElement) sequenceClass).Count;
          if (count > 0)
            list.Add(sequenceClass);
        }
        while (count > 0);
        return list.ToArray();
      }
    }

    public MT973()
      : base(true)
    {
    }

    public MT973(SwiftMessage message)
      : base(message)
    {
    }

    public MT973.SequenceClass AddSequence()
    {
      return new MT973.SequenceClass((SwiftElement) this, this.Sequence.Length, true);
    }

    public void RemoveSequence(MT973.SequenceClass sequence)
    {
      foreach (SwiftTag tag in this.ListTags((SwiftElement) sequence))
        this.RemoveTag(tag);
    }

    internal override SwiftMessageDefinition MsgDefinition()
    {
      return MT973.MessageDefinition;
    }

    protected override void InitSwiftMessageDefinition()
    {
      MT973.MessageDefinition = new SwiftMessageDefinition("MT973", "Netting Request Message");
      MT973.U0002 = new SwiftTagDefinition("TransactionReferenceNumber_20", "Transaction Reference Number");
      MT973.U0002.TagName = ":20:";
      MT973.U0003 = new SwiftTagSubItemDefinition("Reference", "Reference");
      MT973.U0002.Elements.Add((SwiftDefinitionElement) MT973.U0003);
      MT973.MessageDefinition.Elements.Add((SwiftDefinitionElement) MT973.U0002);
      MT973.U0004 = new SwiftTagSequenceDefinition("Sequence", "Message Requested");
      MT973.U0004.Multiple = true;
      MT973.U0005 = new SwiftTagDefinition("MessageRequested_12", "Message Requested");
      MT973.U0005.TagName = ":12:";
      MT973.U0006 = new SwiftTagSubItemDefinition("MessageRequested", "Message Requested");
      MT973.U0005.Elements.Add((SwiftDefinitionElement) MT973.U0006);
      MT973.U0004.Elements.Add((SwiftDefinitionElement) MT973.U0005);
      MT973.U0007 = new SwiftTagDefinition("AccountIdentification_25", "Account Identification");
      MT973.U0007.TagName = ":25:";
      MT973.U0008 = new SwiftTagSubItemDefinition("Account", "Account");
      MT973.U0007.Elements.Add((SwiftDefinitionElement) MT973.U0008);
      MT973.U0004.Elements.Add((SwiftDefinitionElement) MT973.U0007);
      MT973.MessageDefinition.Elements.Add((SwiftDefinitionElement) MT973.U0004);
    }

    public class SequenceClass : SwiftTagSequence
    {
      internal override SwiftDefinitionElement Definition
      {
        get
        {
          return (SwiftDefinitionElement) MT973.U0004;
        }
      }

      [Description("Message Requested")]
      public Tag12 MessageRequested_12
      {
        get
        {
          return new Tag12((SwiftElement) this, 0, (SwiftDefinitionElement) MT973.U0005);
        }
      }

      [Description("Message Requested")]
      public Tag12 Tag12_MessageRequested
      {
        get
        {
          return this.MessageRequested_12;
        }
      }

      [Description("Account Identification")]
      public Tag25 AccountIdentification_25
      {
        get
        {
          return new Tag25((SwiftElement) this, 0, (SwiftDefinitionElement) MT973.U0007);
        }
      }

      [Description("Account Identification")]
      public Tag25 Tag25_AccountIdentification
      {
        get
        {
          return this.AccountIdentification_25;
        }
      }

      internal SequenceClass(SwiftElement parent, int index, bool createTags)
        : base(parent, index, createTags)
      {
      }
    }
  }
}
